[
    async function( kuo,Context,context){
        var $THIS = this;
        Context.Cache = false;
        let $DATA = Object.assign({},this.$DATA);
        let $Security = await Mem.Get('session/'+kuo.sessionid);
        if(!$Security ){
            $Security={
                uid:0,
                code:0,
                tuid:0
            };
        }else if(!$Security.uid){
            $Security.uid = 0;
        }

        if($Security.uid > 0){
            $DATA.data = {list:[],task:{qian:0,shi:0,shiname:"0/3",jiangli:[0.5,0.5]}};
            $DATA.code = 1;
            let PAGE = Mode("Tools").Int(kuo.post["page"]?kuo.post["page"]:1);
            let $MEYE = Mode("Tools").Int(kuo.post["num"]?kuo.post["num"]:20);
            let token = kuo.post["token"]?kuo.post["token"]:"";
            if($MEYE < 1){
                $MEYE = 20;
            }else if($MEYE > 100){
                $MEYE = 100;
            }
            if(PAGE < 0){
                PAGE = 1;
            }
            let ACTION = kuo.post["action"]?kuo.post["action"]:"get";
            let  $features = await Kuoplus(kuo.class);
            if(ACTION == "shiping"){
                let GOqian = true;
                let $TASK = await Mem.Get('task/'+$Security.uid);
                if(!$TASK){
                    $TASK = {
                        time:0, /* 记录时间 */
                        qtime:0,/*签到日期*/
                        qcishu:0,/*签到次数*/
                        shiping:0,/*视频次数*/
                        stime:0,/*视频日期*/
                        token:"",
                    };
                }
                let jinri = Mode("Tools").Date("Ymd");
                let Meici = Mode("Tools").Int($features['configure']['视频次数']?$features['configure']['视频次数'][0]:3);
                let JIANGLI = Mode("Tools").Jine($features['configure']['视频次数']?$features['configure']['视频次数'][1]:0.5);
                if($TASK.stime != jinri){
                    $TASK.shiping = 0;
                }
                if(Mode("Tools").Time() < $TASK.time && $TASK.time >0 ){
                    GOqian = false;
                }

                if(Meici <= $TASK.shiping ){
                    GOqian = false;
                }

                $DATA.code = 0;
                $DATA.data = 0;
                let $TOKEN = Mode("Tools").Uuid();
                if(GOqian && token == $TASK.token){
                    $TASK.token = $TOKEN;
                    await Mem.Set('task/'+$Security.uid,$TASK);
                    let fanhui = await jiaqian ($Security.uid, 1 ,   JIANGLI , 0 , 0 , jinri+'_'+$TASK.qcishu , kuo.ip , kuo.class , "" );
                    if(fanhui){
                        $DATA.code = 1;
                        $DATA.data = fanhui.money;
                        $TASK.stime = jinri;
                        $TASK.shiping++;
                        $TASK.time = Mode("Tools").Time()+16;
                    }
                    await Mem.Set('task/'+$Security.uid,$TASK);
                    $DATA.token = $TOKEN;
                }
 
        
            }else if(ACTION == "qian"){
                let GOqian = false;
                let $TASK = await Mem.Get('task/'+$Security.uid);
                if(!$TASK){
                    $TASK = {
                        time:0, /* 记录时间 */
                        qtime:0,/*签到日期*/
                        qcishu:0,/*签到次数*/
                        shiping:0,/*视频次数*/
                        stime:0,/*视频日期*/
                        token:"",
                    };
                }
                let jinri = Mode("Tools").Date("Ymd");
                if($TASK.qtime !=  jinri){
                    GOqian = true;
                    if(jinri - $TASK.qtime != 1){
                        $TASK.qcishu = 0;
                    }
                }
          
                let qiandao = $features['configure']['签到奖励']?$features['configure']['签到奖励']:[0.5];
                let qiandao_ = Mode("Tools").Jine(qiandao[0]?qiandao[0]:0.5);
                if(qiandao[$TASK.qcishu]){
                    qiandao_ = Mode("Tools").Jine(qiandao[$TASK.qcishu]);
                }else if($TASK.qcishu >=qiandao.length ){
                    qiandao_ = Mode("Tools").Jine(qiandao[qiandao.length-1]);
                }
                $DATA.code = 0;
                $DATA.data = 0;
                let $TOKEN = Mode("Tools").Uuid();
                if(GOqian && token == $TASK.token){
                    
                    $TASK.token = $TOKEN;
                    await Mem.Set('task/'+$Security.uid,$TASK);
                    let fanhui = await jiaqian ($Security.uid, 0 ,   qiandao_ , 0 , 0 , jinri+'_'+$TASK.qcishu , kuo.ip , kuo.class , "" );
                    if(fanhui){
                        $DATA.code = 1;
                        $DATA.data = fanhui.money;
                        $TASK.qtime = jinri;
                        $TASK.qcishu++;
                    }
                    await Mem.Set('task/'+$Security.uid,$TASK);
                    $DATA.token = $TOKEN;
                }

            }else if(ACTION == "get"){
                let $TASK = await Mem.Get('task/'+$Security.uid);
                if(!$TASK){
                    $TASK = {
                        time:0, /* 记录时间 */
                        qtime:0,/*签到日期*/
                        qcishu:0,/*签到次数*/
                        shiping:0,/*视频次数*/
                        stime:0,/*视频日期*/
                        token:"",
                    };
                }
                if(PAGE == 1){
                    let jinri = Mode("Tools").Date("Ymd");
                    if($TASK.qtime !=  jinri){
                        $DATA.data.task.qian = 1;
                        if(jinri - $TASK.qtime != 1){
                            $TASK.qcishu = 0;
                        }
                    }

                    let Meici = Mode("Tools").Int($features['configure']['视频次数']?$features['configure']['视频次数'][0]:3);
                    let JIANGLI = Mode("Tools").Jine($features['configure']['视频次数']?$features['configure']['视频次数'][1]:0.5);
                    let qiandao = $features['configure']['签到奖励']?$features['configure']['签到奖励']:[0.5];
                    let qiandao_ = Mode("Tools").Jine(qiandao[0]?qiandao[0]:0.5);
                    if(qiandao[$TASK.qcishu]){
                        qiandao_ = Mode("Tools").Jine(qiandao[$TASK.qcishu]);
                    }else if($TASK.qcishu >=qiandao.length ){
                        qiandao_ = Mode("Tools").Jine(qiandao[qiandao.length-1]);
                    }
                    $DATA.data.task.shi = 1;

                    if($TASK.stime != jinri){
                        $TASK.shiping = 0;
                    }
    
                    if(Mode("Tools").Time() < $TASK.time && $TASK.time >0 ){
                        $DATA.data.task.shi = 0;
                    }
                    
                    if(Meici <= $TASK.shiping ){
                        $DATA.data.task.shi = 0;
                    }

                    let $TOKEN = Mode("Tools").Uuid();
                    $TASK.token = $TOKEN;
                    await Mem.Set('task/'+$Security.uid,$TASK);
                    $DATA.token = $TOKEN;
                    $DATA.data.task.shiname = $TASK.shiping +"/"+Meici;
                    $DATA.data.task.jiangli = [qiandao_,JIANGLI];
                }

                let $db = await db('moneylog');
                let $data  = await $db.Where({uid:$Security.uid}).Limit($MEYE,PAGE).Order("id desc").Select();
                if($data){
                    let $list = [];
                    let $HUANCUN = {};
                    for(var x_ in $data ){
                        let $typename =$data[x_].num >0?"增加": "减少";
                        if(!$HUANCUN[$data[x_].pluginid]){
                            let  $features_ = await Kuoplus($data[x_].pluginid);
                            if($features_){
                                $HUANCUN[$data[x_].pluginid] ={
                                    name:$features_.name,
                                    type:$features_['configure'].moneylog?$features_['configure'].moneylog:[]
                                };
                            }
                        }
                        if($HUANCUN[$data[x_].pluginid]){
                            let xuanze = $HUANCUN[$data[x_].pluginid];
                            $typename = xuanze['name'];
                            if(xuanze.type[$data[x_].type]){
                                $typename +=" "+xuanze.type[$data[x_].type];
                            }
                        }
                        let shuju_ = {
                            time: $data[x_].atime,
                            num:$data[x_].num,
                            type:$data[x_].type,
                            typename:$typename,
                        };
                        $list.push(shuju_);
                    }
                    $DATA.data.list = $list;
                }
            }
        }
        return  json_encode($DATA);
    }
]